package com.dididoctor.patient.Activity.Usercentre.Record;

import android.content.Context;

import com.dididoctor.patient.Activity.ConstantValue;
import com.dididoctor.patient.Bean.Token;
import com.dididoctor.patient.Http.MyHttpResponseHandler;
import com.dididoctor.patient.MV.BasePresenter;
import com.dididoctor.patient.MV.BusinessClient;
import com.dididoctor.patient.MV.Response;
import com.loopj.android.http.RequestParams;

import org.apache.http.Header;

/**
 * Created by Administrator on 2016/4/15.
 */
public class RecordPresenter extends BasePresenter {

    private RecordView view;

    public RecordPresenter(Context context, RecordView view) {
        super(context, view);
        this.view = view;
    }

    public void updatehealth(String job, String agfood, String agpill) {
        RequestParams params = new RequestParams();
        params.put("userId", Token.getId());
        params.put("token", Token.getToken());
        params.put("job", job);
        params.put("agfood", agfood);
        params.put("agpill", agpill);
        BusinessClient.post(ConstantValue.healthmdy, params, new MyHttpResponseHandler() {
            @Override
            public void onMyResponse(Response response) {
                if (response.isSucceed()) {
                    view.updatesucced();
                } else {
                    view.showToastMessage(response.getMsg());
                    view.updatefail();
                }
            }

            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                super.onFailure(i, headers, bytes, throwable);
                view.updatefail();
            }
        });
    }
}
